let cropper = new Cropper($('#image')[0], {
    aspectRatio: 1,
    preview: $('.img-preview')
})

$('.select').on('click', function () {
    $('#file').click()
})

$('#file').on('change', function (e) {
    const file = e.target.file[0]
    const str = URL.createObjectURL(file)
    cropper.replace(str)
})

$('.sure').on('click', function () {
    let canvas = cropper.getCroppedCanvas({
        width: 100,
        height: 100
    })

    let base64Str = canvas.toDataURL('image/jpeg')
    base64Str = encodeURIComponent(base64Str)
    console.log(base64Str)

})